package com.urfresh.sp.flume.api;

import com.urfresh.sp.flume.dto.Res;
import com.urfresh.sp.flume.dto.v2.ClickInfo;
import com.urfresh.sp.flume.dto.v2.OrderInfo;
import com.urfresh.sp.flume.dto.v2.PageInfo;
import com.urfresh.sp.flume.dto.v2.SysInfo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by urfresh.mark on 2016/8/29.
 */
public interface ClientAPI {

    @RequestMapping(value = "/login/{sign}", method = RequestMethod.POST)
    public Res login(
            HttpServletRequest request,
            @ApiParam(name = "sign", value = "", required = true)
                    String sign,
            @ApiParam(name = "app启动时候的基础数据对象", value = "", required = true)
                    SysInfo sysInfo);

    /**
     * 从H5落地页提交的数据
     *
     * @param request
     * @return
     */
    @ApiOperation(value = "接收H5渠道落地页的提交请求")
    @ApiResponses(value = {
            @ApiResponse(code = 500, message = "服务器内部错误"),
            @ApiResponse(code = 400, message = "提交的参数不正确"),
            @ApiResponse(code = 201, message = "提交成功")}
    )
    public void pageInfo(HttpServletRequest request,
                         @ApiParam(name = "页面属性", value = "", required = true)
                                 PageInfo pageInfo);

    ////////////////////////////////////////////////////////////////////////////////////////////////////////

    @ApiOperation(value = "app启动时提交的埋点数据，包含app版本和手机设备数据等基础信息", response = Res.class, notes = "rst=-1表示验证失败")
    @ApiResponses(value = {
            @ApiResponse(code = 500, message = "服务器内部错误"),
            @ApiResponse(code = 400, message = "提交的参数不正确"),
            @ApiResponse(code = 201, message = "提交成功")}
    )
    public Res sysInfo(HttpServletRequest request,
                       @ApiParam(name = "sign", value = "", required = true)
                               String sign,
                       @ApiParam(name = "app启动时候的基础数据对象", value = "", required = true)
                               SysInfo sysInfo);


    @ApiOperation(value = "sys_info的批量提交版本", response = Res.class, notes = "rst=-1表示验证失败")
    @ApiResponses(value = {
            @ApiResponse(code = 500, message = "服务器内部错误"),
            @ApiResponse(code = 400, message = "提交的参数不正确"),
            @ApiResponse(code = 201, message = "提交成功")}
    )
    public Res sysList(HttpServletRequest request,
                       @ApiParam(name = "sign", value = "", required = true)
                               String sign,
                       @ApiParam(name = "json", value = "", required = true)
                               List<SysInfo> data);

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////

    @ApiOperation(value = "订单生成时提交的埋点数据", response = Res.class, notes = "rst=-1表示验证失败")
    @ApiResponses(value = {
            @ApiResponse(code = 500, message = "服务器内部错误"),
            @ApiResponse(code = 400, message = "提交的参数不正确"),
            @ApiResponse(code = 201, message = "提交成功")}
    )
    public Res orderInfo(
            @ApiParam(name = "sign", value = "", required = true)
                    String sign,
            @ApiParam(name = "订单信息，包含订单id，使用到的促销券id，订单类型", value = "", required = true)
                    OrderInfo orderInfo);


    @ApiOperation(value = "order_info的批量提交版本", response = Res.class, notes = "rst=-1表示验证失败")
    @ApiResponses(value = {
            @ApiResponse(code = 500, message = "服务器内部错误"),
            @ApiResponse(code = 400, message = "提交的参数不正确"),
            @ApiResponse(code = 201, message = "提交成功")}
    )
    public Res orderList(
            @ApiParam(name = "sign", value = "", required = true)
                    String sign,
            @ApiParam(name = "json", value = "", required = true)
                    List<OrderInfo> data);

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////

    @ApiOperation(value = "用户在app发生点击事件时产生的埋点数据，目前包含点击渠道和商品时产生的信息", response = Res.class, notes = "rst=-1表示验证失败")
    @ApiResponses(value = {
            @ApiResponse(code = 500, message = "服务器内部错误"),
            @ApiResponse(code = 400, message = "提交的参数不正确"),
            @ApiResponse(code = 201, message = "提交成功")}
    )
    public Res clickInfo(
            @ApiParam(name = "sign", value = "", required = true)
                    String sign,
            @ApiParam(name = "点击产生的信息，包含点击元素的内容，点击次数，元素的值等", value = "", required = true)
                    ClickInfo clickInfo);

    @ApiOperation(value = "click_info的批量提交版本", response = Res.class, notes = "rst=-1表示验证失败")
    @ApiResponses(value = {
            @ApiResponse(code = 500, message = "服务器内部错误"),
            @ApiResponse(code = 400, message = "提交的参数不正确"),
            @ApiResponse(code = 201, message = "提交成功")}
    )
    public Res clickList(
            @ApiParam(name = "sign", value = "", required = true)
                    String sign,
            @ApiParam(name = "json", value = "", required = true)
                    List<ClickInfo> data);

    final String IMPLANT_SYS_SINK = "urfresh.flume.implant.sys";
    final String IMPLANT_ORDER_SINK = "urfresh.flume.implant.order";
    final String IMPLANT_CLICK_SINK = "urfresh.flume.implant.click";
    final String IMPLANT_PAGE_SINK = "urfresh.flume.implant.page";

}
